<% @filter = params[:filter].to_s.humanize.downcase %>
<% content_for :action_nav do %>
<div id="page-nav">
  <ul id="act-nav" class="clear">
    <% if controller.controller_name == 'comments' && controller.action_name == 'index' && @comments.size > 0 -%>
      <li><%= link_to_remote "Delete these #{@filter != 'all' ? @filter : ''} comments", :confirm => "Are you sure you wish to delete all #{@filter != 'all' ? @filter : ''} comments?",
          :url => { :controller => 'comments', :action => 'destroy', :id => @article }, :with => "ArticleForm.getAvailableComments().toQueryString('comment')"
        %></li>
    <% end -%>
  <% if @article && (admin? || @article.user_id == current_user.id) && @article.comment_age != -1 -%>
    <li id="close-article-comments"><%= link_to_remote 'Close comments for this article', 
      :url => { :controller => 'admin/comments', :action => 'close', :id => @article } %></li>
  <% end -%>
  <% if controller.action_name == 'edit' -%>
    <li><%= link_to('Preview', {:action => 'show', :id => @article}, {:target => '_blank'}) %></li>
  <% end -%>
    <li id="select">
      <a class="trigger" id="cog" href="#">&nbsp;</a>
      <div id="optgroup" style="display: none">
        <ul id="options">
        <% unless @article.nil? || @article.new_record? -%>
          <li><%= link_to 'Edit this article', :controller => 'articles', :action => 'edit', :id => @article, :version => nil %></li>
        <% end -%>
        <% if @article && @article.comments.size > 0 && !(controller.controller_name == 'comments' && controller.action_name == 'index') -%>
          <li><%= link_to "View comments", :controller => 'comments', :action => 'index', :article_id => @article %></li>
        <% end %>
				<% if @article && (admin? || @article.user_id == current_user.id) -%>
					<li><%= link_to_remote 'Delete this article', :url => article_path(@article), :method => :delete, :confirm => 'Are you sure you want to delete this article?' %></li>
				<% end -%>
        </ul>
      </div>
    </li>
  </ul>
</div>

<div id="filter" class="manual">
  <ul class="clear">
    <li><a href="#">&nbsp;</a></li>
  </ul>
  <ul id="attributes">
    <% if @article && controller.controller_name == 'articles' && controller.action_name == 'edit' -%>
    <li><label for="search">Revision:</label></li>
    <li>
      <select name="filter" id="revisionnum">
        <option value="0">Newest</option>
        <%= options_from_collection_for_select @article.versions.reverse, :version, :version, params[:version].to_i %>
      </select>
    </li>
    <% end -%>
    <% if controller.controller_name == 'comments' && controller.action_name == 'index' -%>
    <li><label for="comments_view">Show comments:</label></li>
    <li>
      <select id="comments-view">
        <%= options_for_select ['All', 'Unapproved', 'Approved'], params[:filter].to_s.humanize %>
      </select>
    </li>
    <% end -%>
  </ul>
</div>
<% end unless @article && @article.new_record? && @article.comments.size == 0 -%>